/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.hcht.xrlh.tj.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.google.common.collect.Lists;
import com.hcht.xrlh.tj.dao.DataStatisticsDao;
import com.hcht.xrlh.tj.entity.DataStatistics;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.modules.sys.entity.Office;

/**
 * 检查任务Service
 * @author lrz
 * @version 2016-12-21
 */
@Service
@Transactional(readOnly = true)
public class DataStatisticsService extends CrudService<DataStatisticsDao, DataStatistics> {

	@Autowired
	DataStatisticsDao dao;

/*	public List<TjZhuQuery> findlist(TjZhuQuery tjZhuQuery) {

		List<TjZhuQuery> list = dao.findList(tjZhuQuery);

		return list;
	}*/
	
	/*
	 * 总局事项
	 * */
	public List<DataStatistics> queryZj_SX(){
		List<DataStatistics> list = dao.queryZj_SX();
		return list;
	}
	
	/*
	 * 直属局事项
	 * */
	public List<DataStatistics> queryZsj_SX_Main(){
		List<DataStatistics> list = dao.queryZsj_SX_Main();
		return list;
	}
	
	
	/*
	 * 直属局事项分组
	 * */
	public List<DataStatistics> queryZsj_SX_Detail(){
		List<DataStatistics> list = dao.queryZsj_SX_Detail();
		return list;
	}
	/*
	 * 分支机构事项
	 * */
	public List<DataStatistics> queryFzjg_SX_Main(){
		List<DataStatistics> list = dao.queryFzjg_SX_Main();
		return list;
	}
	/*
	 * 分支机构事项分组
	 * */
	public List<DataStatistics> queryFzjg_SX_Detail(){
		List<DataStatistics> list = dao.queryFzjg_SX_Detail();
		return list;
	}	
	
	/*
	 * 总局计划
	 * */
	public List<DataStatistics> queryZj_JH(){
		List<DataStatistics> list = dao.queryZj_JH();
		return list;
	}	
	/*
	 * 直属局计划
	 * */
	public List<DataStatistics> queryZsj_JH_Main(){
		List<DataStatistics> list = dao.queryZsj_JH_Main();
		return list;
	}	
	
	/*
	 * 直属局计划分组
	 * */
	public List<DataStatistics> queryZsj_JH_detail(){
		List<DataStatistics> list = dao.queryZsj_JH_detail();
		return list;
	}	
	/*
	 * 分支机构计划
	 * */
	public List<DataStatistics> queryFzjg_JH_Main(){
		List<DataStatistics> list = dao.queryFzjg_JH_Main();
		return list;
	}
	/*
	 * 分支机构计划分组
	 * */
	public List<DataStatistics> queryFzjg_JH_detail(){
		List<DataStatistics> list = dao.queryFzjg_JH_detail();
		return list;
	}	
	
	/*
	 * 总局任务数
	 * */
	public List<DataStatistics> queryZj_RW(){
		List<DataStatistics> list = dao.queryZj_RW();
		return list;
	}	
	
	/*
	 * 直属局任务数
	 * */
	public List<DataStatistics> queryZsj_RW(){
		List<DataStatistics> list = dao.queryZsj_RW();
		return list;
	}	
	/*
	 * 直属局任务数分组 
	 * */
	public List<DataStatistics> queryZsj_RW_detail(){
		List<DataStatistics> list = dao.queryZsj_RW_detail();
		return list;
	}

	/*
	 * 分支机构任务数 
	 * */
	public List<DataStatistics> queryFzjg_RW(){
		List<DataStatistics> list = dao.queryFzjg_RW();
		return list;
	}
	/*
	 * 分支机构任务数分组 
	 * */
	public List<DataStatistics> queryFzjg_RW_detail(){
		List<DataStatistics> list = dao.queryFzjg_RW_detail();
		return list;
	}
	
	/*
	 * 人员库库存
	 * */
	public List<DataStatistics> queryKc_Ry(){
		List<DataStatistics> list = dao.queryKc_Ry();
		return list;
	}
	
	/*
	 * 对象库库存
	 * */
	public List<DataStatistics> queryKc_Dx(){
		List<DataStatistics> list = dao.queryKc_Dx();
		return list;
	}
	
	/*
	 * 人员库选中
	 * */
	public List<DataStatistics> queryXz_Ry(){
		List<DataStatistics> list = dao.queryXz_Ry();
		return list;
	}
	
	/*
	 * 对象库选中
	 * */
	public List<DataStatistics> queryXz_Dx(){
		List<DataStatistics> list = dao.queryXz_Dx();
		return list;
	}
	
	/*
	 * 人员在库详细
	 * */
	public List<DataStatistics> queryKc_Ry_xx(){
		List<DataStatistics> list = dao.queryKc_Ry_xx();
		List<DataStatistics> list_return = Lists.newArrayList();
		DataStatistics zj = new DataStatistics();
		zj.setCount((long)0);
		Office zj_o = new Office();
		zj_o.setName("总局事项");
		zj.setOffice(zj_o);
		DataStatistics zsj = new DataStatistics();
		zsj.setCount((long)0);
		Office zsj_o = new Office();
		zsj_o.setName("直属局事项");
		zsj.setOffice(zsj_o);
		DataStatistics fzjg = new DataStatistics();
		fzjg.setCount((long)0);
		Office fzjg_o = new Office();
		fzjg_o.setName("分支机构事项");
		fzjg.setOffice(fzjg_o);
		for(DataStatistics d:list){
			if("0".equals(d.getOffice().getId())){
				zj.setCount(zj.getCount()+d.getCount());
			}else{
				if("1".equals(d.getOffice().getName())){
					zsj.setCount(zsj.getCount()+d.getCount());
				}else if("2".equals(d.getOffice().getName())){
					fzjg.setCount(fzjg.getCount()+d.getCount());
				}
			}
		}
		list_return.add(zj);
		list_return.add(zsj);
		list_return.add(fzjg);
		return list_return;
	}
	
	/*
	 * 对象在库详细
	 * */
	public List<DataStatistics> queryKc_Dx_xx(){
		List<DataStatistics> list = dao.queryKc_Dx_xx();
		List<DataStatistics> list_return = Lists.newArrayList();
		DataStatistics zj = new DataStatistics();
		zj.setCount((long)0);
		Office zj_o = new Office();
		zj_o.setName("总局事项");
		zj.setOffice(zj_o);
		DataStatistics zsj = new DataStatistics();
		zsj.setCount((long)0);
		Office zsj_o = new Office();
		zsj_o.setName("直属局事项");
		zsj.setOffice(zsj_o);
		DataStatistics fzjg = new DataStatistics();
		fzjg.setCount((long)0);
		Office fzjg_o = new Office();
		fzjg_o.setName("分支机构事项");
		fzjg.setOffice(fzjg_o);
		for(DataStatistics d:list){
			if("0".equals(d.getOffice().getId())){
				zj.setCount(zj.getCount()+d.getCount());
			}else{
				if("1".equals(d.getOffice().getName())){
					zsj.setCount(zsj.getCount()+d.getCount());
				}else if("2".equals(d.getOffice().getName())){
					fzjg.setCount(fzjg.getCount()+d.getCount());
				}
			}
		}
		list_return.add(zj);
		list_return.add(zsj);
		list_return.add(fzjg);
		return list_return;
	}	
	
	/*
	 * 选中人员详细
	 * */
	public List<DataStatistics> queryXz_Ry_xx(){
		List<DataStatistics> list = dao.queryXz_Ry_xx();
		List<DataStatistics> list_return = Lists.newArrayList();
		DataStatistics zj = new DataStatistics();
		zj.setCount((long)0);
		Office zj_o = new Office();
		zj_o.setName("总局事项");
		zj.setOffice(zj_o);
		DataStatistics zsj = new DataStatistics();
		zsj.setCount((long)0);
		Office zsj_o = new Office();
		zsj_o.setName("直属局事项");
		zsj.setOffice(zsj_o);
		DataStatistics fzjg = new DataStatistics();
		fzjg.setCount((long)0);
		Office fzjg_o = new Office();
		fzjg_o.setName("分支机构事项");
		fzjg.setOffice(fzjg_o);
		for(DataStatistics d:list){
			if("0".equals(d.getOffice().getId())){
				zj.setCount(zj.getCount()+d.getCount());
			}else{
				if("1".equals(d.getOffice().getName())){
					zsj.setCount(zsj.getCount()+d.getCount());
				}else if("2".equals(d.getOffice().getName())){
					fzjg.setCount(fzjg.getCount()+d.getCount());
				}
			}
		}
		list_return.add(zj);
		list_return.add(zsj);
		list_return.add(fzjg);
		return list_return;
	}	
	
	/*
	 * 选中对象详细
	 * */
	public List<DataStatistics> queryXz_Dx_xx(){
		List<DataStatistics> list = dao.queryXz_Dx_xx();
		List<DataStatistics> list_return = Lists.newArrayList();
		DataStatistics zj = new DataStatistics();
		zj.setCount((long)0);
		Office zj_o = new Office();
		zj_o.setName("总局事项");
		zj.setOffice(zj_o);
		DataStatistics zsj = new DataStatistics();
		zsj.setCount((long)0);
		Office zsj_o = new Office();
		zsj_o.setName("直属局事项");
		zsj.setOffice(zsj_o);
		DataStatistics fzjg = new DataStatistics();
		fzjg.setCount((long)0);
		Office fzjg_o = new Office();
		fzjg_o.setName("分支机构事项");
		fzjg.setOffice(fzjg_o);
		for(DataStatistics d:list){
			if("0".equals(d.getOffice().getId())){
				zj.setCount(zj.getCount()+d.getCount());
			}else{
				if("1".equals(d.getOffice().getName())){
					zsj.setCount(zsj.getCount()+d.getCount());
				}else if("2".equals(d.getOffice().getName())){
					fzjg.setCount(fzjg.getCount()+d.getCount());
				}
			}
		}
		list_return.add(zj);
		list_return.add(zsj);
		list_return.add(fzjg);
		return list_return;
	}			
	
	
	
	/*
	 * 日常施检工作事项
	 * */
	public List<DataStatistics> queryRc_SX_Main(){
		List<DataStatistics> list = dao.queryRc_SX_Main();
		return list;
	}
	
	/*
	 * 日常施检工作事项分组
	 * */
	public List<DataStatistics> queryRc_SX_Detail(){
		List<DataStatistics> list = dao.queryRc_SX_Detail();
		return list;
	}
	
	/*
	 * 日常计划
	 * */
	public List<DataStatistics> queryRc_JH_Main(){
		List<DataStatistics> list = dao.queryRc_JH_Main();
		return list;
	}
	/*
	 * 日常计划分组
	 * */
	public List<DataStatistics> queryRc_JH_detail(){
		List<DataStatistics> list = dao.queryRc_JH_detail();
		return list;
	}	
	
	/*
	 * 日常任务数 
	 * */
	public List<DataStatistics> queryRc_RW(){
		List<DataStatistics> list = dao.queryRc_RW();
		return list;
	}
	/*
	 * 日常任务数分组 
	 * */
	public List<DataStatistics> queryRc_RW_detail(){
		List<DataStatistics> list = dao.queryRc_RW_detail();
		return list;
	}
}